package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.StrategyDetailComment;
import cn.wolfcode.trip.base.mapper.StrategyDetailCommentMapper;
import cn.wolfcode.trip.base.query.CommentQueryObject;
import cn.wolfcode.trip.base.service.IStrategyDetailCommentService;
import cn.wolfcode.trip.base.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StrategyDetailCommentServiceImpl implements IStrategyDetailCommentService {
    @Autowired
    private StrategyDetailCommentMapper strategyDetailCommentMapper;

    @Override
    public PageInfo query(CommentQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<StrategyDetailComment> list = strategyDetailCommentMapper.queryForList(qo);
        return new PageInfo(list);
    }

    @Override
    public void saveOrUpdate(StrategyDetailComment strategyDetailComment) {
        if (strategyDetailComment.getId() != null) {
            strategyDetailCommentMapper.updateByPrimaryKey(strategyDetailComment);
        } else {
            //设置当前用户
            strategyDetailComment.setUser(UserContext.getCurrentUser());
            strategyDetailCommentMapper.insert(strategyDetailComment);
        }

    }

    @Override
    public List<StrategyDetailComment> listAll() {
        return null;
    }

    @Override
    public StrategyDetailComment get(Long id) {
        return null;
    }

    @Override
    public void saveOrUpdate(StrategyDetailComment strategyDetailComment, String[] tags) {

    }

    @Override
    public Integer queryCountByStrategyDetailCommentId(Long strategyStrategyDetailCommentId) {
        return strategyDetailCommentMapper.queryCountByStrategyDetailCommentId(strategyStrategyDetailCommentId);
    }
}
